<template>
    <div class="personDetail">
        <wtop></wtop>
        <div class="center">
            <div class="right">
                <!-- <div class="where">当前位置：外呼系统>任务管理>{{taskname}}人员拨打详情</div> -->

                <div style="height: 16px; width: 100%; background: #EFEFEF;"></div>
                <div class="taskMission">
                  <div class="title">{{taskname}}人员拨打详情</div>
                </div>
                <div class="conlist" v-loading='loading'>
                    <div class="flex">
                        <div class="gong gl">
                          <el-form :inline="true" :model="formInline">
                            <el-form-item label="任务名称">
                              <el-input v-model="formInline.name" placeholder="任务名称"></el-input>
                            </el-form-item>
                            <el-form-item label="号码">
                              <el-input v-model="formInline.mobile" placeholder="号码"></el-input>
                            </el-form-item>
                            <el-form-item>
                              <el-button type="danger" @click="search">检索</el-button>
                            </el-form-item>
                          </el-form>
                        </div>
                    </div>
                    <div class="list">
                        <div class="th">业务ID</div>
                        <div class="th">所属任务</div>
                        <div class="th">任务类型</div>
                        <div class="th">拨打时间</div>
                        <div class="th">外呼目标达成</div>
                        <div class="th td2">操作</div>
                    </div>
                    <div class="list" v-for="item in list" :key="item.id">
                        <div class="td">{{item.mission_id}}</div>
                        <div class="td">{{item.task_name}}</div>
                        <div class="td">{{item.type_name}}</div>
                        <div class="td">{{item.call_at}}</div>
                        <div class="td">{{item.result}}</div>
                        <div class="td td2">
                          <div class="audioplay" v-if="item.record">
                          	<audio class="audio" controls>
                              <source :src="item.record" type="audio/mpeg">
                          		<!-- <source :src="'/storage/upload/record/'+item.record" type="audio/mpeg"> -->
                          		您的浏览器不支持 audio 元素。
                          	</audio>
                          </div>
                        </div>
                    </div>
                    <el-pagination background layout="total,prev, pager, next" :current-page="page" @current-change="fanye" :page-size="pagesize" :total="total"></el-pagination>
                </div>
            </div>
        </div>

        <wfoot></wfoot>
    </div>

</template>

<script>
    import axios from 'axios'
    import wtop from '@/components/callsystem/wtop.vue'
    import wfoot from '@/components/callsystem/wfoot.vue'
    import moment from "moment";

    export default {
        components: {
            "wtop": wtop,
            "wfoot": wfoot
        },
        name: "personDetail",
        data() {
            return {
                total:0,
                pagesize:20,
                page:1,
                list:[],
                loading:false,
                mobile:"",
                startCall: false,
                id: '',
                taskname: '',
                formInline: {
                  name: '',
                  mobile: ''
                },
            }
        },
        created() {
          this.id = this.$route.query.id
          this.getlist()
        },
        mounted() {

        },
        methods: {
            search:function(){
              this.page = 1
                this.getlist()
            },
            //翻页
            fanye:function(page){
            	this.loading = true
            	this.page = page
            	this.getlist()
            },
            //获取列表
            getlist:function(){
                var that = this
                this.loading = true
                axios.get(`/api/plan-market/user/call/logs?id=${this.id}&task_name=${this.formInline.name}&mobile=${this.formInline.mobile}&page=${this.page}&page_size=${this.pagesize}`)
                	.then(response => {
                		if(response.data.msg.code == 0){
                      that.taskname = response.data.data.user_name
                      that.list = response.data.data.list.data
                      let resultArr = ['未达成','已达成']
                      for(let i in that.list){
                        that.list[i].result = resultArr[that.list[i].result]
                      }
                      that.total = response.data.data.list.total
                      that.loading = false
                		}else{
                			that.$message.error(response.data.msg.info);
                		}
                	})
            },
            //下面使用的格式化时间
            formatDate:function(numb) {
              const time = new Date((numb - 1) * 24 * 3600000 + 1)
              time.setYear(time.getFullYear() - 70)
              const year = time.getFullYear() + ''
              const month = time.getMonth() + ''
              let date = time.getDate() + ''
              if(time.getFullYear()%4 === 0){
                var X = moment([year, month, date]).subtract(1, 'days').format('YYYY-MM-DD');
              }else{
                var X = moment([year, month, date]).format('YYYY-MM-DD');
              }
              return X
            },
        }
    }
</script>

<style lang="scss" scoped>
    .personDetail{ margin: 0; padding: 0; background: #EFEFEF;
        .listupload{ font-size: 14px;
            .li{flex: 1; line-height: 38px; margin-top: 20px;}
            .el-button--primary{ background: #ffffff; color: #409EFF; border-color: #409EFF; }

        }
        .center{ min-width: 1366px;width: 1366px; margin: 0 auto; display: flex; justify-content: space-between;
    		.right{ flex-basis: 1366px; background: #ECECEC;
              .title{border-bottom: 1px #EAEAEA solid;  line-height: 45px; padding-left: 30px; font-size: 16px; background: #F9F9F9; color: #727272}
              .taskMission{
                background: #fff;font-size: 14px;
                .content{padding: 20px 20px;color: #727272;font-size: 14px;
                  .ht{padding-bottom: 20px;display: flex;
                    .tab{width: 100px;text-align: right;}
                  }
                }
              }
            }
            .powertop{ display: flex; width: 640px; }
            .powertopli{ flex-basis: 160px; line-height: 45px; border-top: 4px #EBECEF solid; color: #727272; border-right: 1px #EAEAEA solid; font-size: 14px; text-align: center;}
            .powertopact{ background: #FFFFFF; border-top: 4px #DD2727 solid;}
            .con{  background: #FFFFFF; padding: 30px 40px; display: flex; justify-content: space-between;
                .conleft{
                    .flex{ display: flex; margin-bottom: 20px;}
                    .gong{ margin-right: 30px; color: #333}
                }
                .conright{
                    .el-input__inner{ line-height: 40px !important; height: 40px !important;}
                }
            }
            .conlist{ padding: 30px; background: #FFFFFF;
                .flex{ display: flex; justify-content: space-between}
                .gong{ display: flex;
                    .el-date-editor.el-input{ width: 200px;}
                    .el-input__inner{ width: 250px;}
                    .el-button--danger{ margin-left: 20px;}
                    .el-button--primary{ padding: 10px 30px; background: #EEF7FF; border: 1px #EEF7FF solid; margin-left: 20px;}
                    .el-date-editor--month{ margin-right: 20px;}
                }
                .gl{ margin-bottom: 20px;
                    .el-input__inner{ width: 200px !important; }
                    .el-button--danger{ margin-left: 0px !important; margin-right: 20px;}
                }
                .ml{
                  .el-button--danger{ margin-left: 10px!important;}
                }
                .list{ display: flex; border-bottom: 1px #eaeaea solid;align-items: center;
                    .th{ background: #EAEAEA; text-align: center; flex: 1; padding: 15px 0; font-size: 14px;}
                    .td{ background: #ffffff; text-align: center; flex: 1; padding: 15px 0; font-size: 14px;}
                    .td2{ flex: 2}
                }
                .el-pagination{ text-align: right; margin: 20px 0}
            }
    	}
      .formflex{display: flex;justify-content: space-between;
        .el-input__inner{ width: 200px; }
        .lineflex{display: flex;
          .el-button--text{height: 40px;margin-left: 20px;}
        }

      }
      .formsubmit{justify-content: center;}
      .audioplay{
        #audio{
          height: 34px;
          &:focus {
            outline: -webkit-focus-ring-color auto 0px;
          }
        }
      }
    }
</style>
